<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>修改卖盘池</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1" name="viewport">
<meta content="" name="description">
<meta content="" name="author">
<link href="${request.getContextPath()}/Public/assets/admin/css/css.css" rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/assets/global/plugins/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/assets/global/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/assets/global/plugins/uniform/css/uniform.default.css" rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/assets/global/plugins/jquery-ui/jquery-ui.min.css" rel="stylesheet" type="text/css">

<link href="${request.getContextPath()}/Public/assets/global/css/components-rounded.css" id="style_components" rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/assets/global/css/plugins.css" rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/assets/admin/css/layout.css" rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/assets/admin/css/themes/default.css" rel="stylesheet" type="text/css" id="style_color">
<link href="${request.getContextPath()}/Public/assets/admin/css/custom.css" rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/assets/global/plugins/bootstrap-datepicker/css/bootstrap-datepicker.min.css" rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/assets/admin/css/common.css" rel="stylesheet" type="text/css">



<link rel="shortcut icon" href="${request.getContextPath()}/Public/favicon.ico">
<!--[if lt IE 9]>
<script src="${request.getContextPath()}/Public/assets/global/plugins/respond.min.js"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/excanvas.min.js"></script>
<![endif]-->
<script src="${request.getContextPath()}/Public/assets/global/plugins/jquery.min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/jquery-migrate.min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/jquery-validation/js/jquery.validate.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/jquery-validation/js/localization/messages_zh.min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/jquery-slimscroll/jquery.slimscroll.min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/jquery.blockui.min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/jquery.cokie.min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/uniform/jquery.uniform.min.js" type="text/javascript"></script>

<script src="${request.getContextPath()}/Public/assets/global/plugins/jquery.sparkline.min.js" type="text/javascript"></script>

<script src="${request.getContextPath()}/Public/assets/global/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js" type="text/javascript"></script>

<script src="${request.getContextPath()}/Public/assets/global/scripts/metronic.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/admin/scripts/layout.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/admin/scripts/commonUtils.js" type="text/javascript"></script>

<!-- select2控件 -->
<script type="text/javascript" src="${request.getContextPath()}/Public/assets/global/plugins/select2/select2.js"></script>
<script type="text/javascript" src="${request.getContextPath()}/Public/assets/global/plugins/select2/select2_locale_zh-CN.js"></script>
<link href="${request.getContextPath()}/Public/assets/global/plugins/select2/select2.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="${request.getContextPath()}/Public/js/common/util.js"></script>
</head>
<body class="page-header-top-fixed">
<div class="page-header">
	<!--头部开始-->
	<#include "/include/top.html" />
	<!-- 头部信息结束 -->

	<!-- 头部菜单开始 -->
	<#include "/include/top_menu.html" />
	<!-- 头部菜单结束 -->
</div>
<!-- END HEADER -->
<div class="page-container">
	<div class="page-content">
		<div class="container-fluid">
			<!-- 当前位置提示开始 -->
			<ul class="page-breadcrumb breadcrumb">
				<li>
					<a href="#">首页</a><i class="fa fa-circle"></i>
				<li class="active">
					 撮合管理<i class="fa fa-circle"></i>
				<li class="active">
					 新建卖盘池
			</ul>
			<div class="row margin-top-10">
				<div class="col-md-12">
					<div class="portlet light bordered">
						<form class="form-horizontal" id="dataForm">
						
				  		  <input type="hidden" id="sellId" name="id" value="${sellPool.id!''}">
				  		
						  <div class="form-group">
						    <label  class="col-sm-2 control-label">库存：</label>
						    <div class="col-sm-4">
						      <input type="text" class="form-control" id="quantity" name="quantity" value="${sellPool.quantity}" style="width: 235px;height: 34px;" >
						      <span id="s1" style="color: red"></span>
						    </div>
						  </div>
						  
						 
						  <div class="form-group">
						    <label  class="col-sm-2 control-label">价格：</label>
						    <div class="col-sm-4">
						      <input type="text" class="form-control" id="price" name="price" value="${sellPool.price?string('#.##')}" style="width: 235px;height: 34px;">
						      <span id="s2" style="color: red"></span>
						    </div>
						  </div>
						 
						
						  <div class="form-group">
						    <div class="col-sm-offset-2 col-sm-10">
						    	<button id="notSavetButton" type="button" class="btn  green pull-left">
									返回 <i class="m-icon-swapright m-icon-white"></i>
								</button>
						      	<button type="button"  id="savetButton" class="btn green pull-center">
									提交<i class="m-icon-swapright m-icon-white"></i>
								</button>
						    </div>
						  </div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<!-- 底部开始 -->
<#include "/include/foot.html" />
<!-- 底部结束 -->
</body>
<script>
	
	jQuery(document).ready(function() {
		//如果省不为空，则初始化仓库
		if ($('#wareProvince').val() != null) {
			$("#wareId").append("<option value='"+$("#wareIds").val()+"'>" + $("#wareName").val() + "</option>");
		}
	   
	   Metronic.init(); // init metronic core componets
	   Layout.init(); // init layout
	   checkNum($('#price'));
	   checkNum4($('#quantity'));
	});
	recordDate();
	//初始化日期
	function recordDate() {
		var nowDate = new Date();
        //$('#date-picker').attr("date-date",nowDate.getFullYear()+"/"+parseInt(nowDate.getMonth()+1)+"/"+nowDate.getDate());
        $('.date-picker').datepicker({
    	    autoclose: true	   
    	});
        
        
	}
	
	$("#savetButton").bind("click",function(){
		var  num=/^[0-9]+([.]{1}[0-9]+){0,1}$/;
		
		var quantity=$("#quantity").val();
		var price=$("#price").val();
		
		if (!num.test(quantity) ||  quantity<=0){
		
			$("#s1").html("库存必须大于0的数字");
			return ;
			
		}
		if(  !num.test(price) || price<=0 ){
			$("#s2").html("价格必须大于0的数字");
		
			return ;
			
		}
		
		
		if(!$("#dataForm").validate({
			//数据验证
			rules:{
				wareProvince:"required",
				wareId:"required",
				
				priority:"required",
				unit:"required",
			}
		}).form()){
			return;
		} 
		$.ajax({
			url : "${request.getContextPath()}/dealMake/updateSellPool.do",
			type : "post",
			dataType:"json",
			async: false,
			data : $("#dataForm").serialize(),
			success : function(result) {
			   if(result.code=="success"){
				   	alert("修改成功");
			      		window.location.href="${request.getContextPath()}/dealMake/sellOrder.do";
				}else{
		   		alert(result);	
		   		}
			   }
		});
	});
	
	$("#notSavetButton").bind("click",function(){
		$.ajax({
			url : "${request.getContextPath()}/dealMake/returnSellOrder.do",
			type : "post",
			async: false,
			success : function(result) {
				    if(result.code=="success"){
					      		window.location.href="${request.getContextPath()}/dealMake/sellOrder.do";
					}else {
			   		}
				}
		});
	});
	
	
	function selWareName(value){
		$("#wareId").empty();
		if(value==-1){
			var ops =  document.getElementById("wareId").options;
			ops.length=0;
			ops.add(new Option("请选择仓库",""));
			return;
		}
		$.ajax({
			url : "${request.getContextPath()}/dealMake/selWarehouseByArea.do",
			type : "post",
			dataType:"json", 
			async: false,
			data :{"areaId":value},
			success : function(data) {
			 	var jsonData = eval(data);//接收到的数据转化为JQuery对象，由JQuery为我们处理 
				$("#wareId").append("<option value=''>--请选择--</option>");
				$.each(jsonData, function(index, item) {
					$("#wareId").append(
							"<option value='"+item.id+"'>" + item.name + "</option>");
				}); 
			}
		});
	}
</script>
</html>

